<template>
    <div id="house-loan" class="compute-loan">
        <tab :line-width="2" active-color="rgb(20,93,210)" bar-active-color="rgb(20,93,210)">
            <tab-item selected  @on-item-click="onItemClick">商业贷款</tab-item>
            <tab-item  @on-item-click="onItemClick">公积金贷款</tab-item>
            <tab-item  @on-item-click="onItemClick">组合贷款</tab-item>
        </tab>
        <div class="car-value" >
           <flexbox class="flex-radio" v-if="computeStyle === 0">
                <flexbox-item>
                    <div class="flex-demo" @click="businessFirst">
                        <x-icon type="ios-circle-filled" class="icon-radio" size=".6rem" v-if="iconshow"></x-icon>
                        <x-icon type="ios-circle-outline" size=".6rem" v-if="!iconshow"></x-icon>
                        <label for="one">按贷款金额计算</label>
                    </div>
                </flexbox-item>
                <flexbox-item>
                    <div class="flex-demo" @click="businessSecond">
                          <x-icon type="ios-circle-filled" class="icon-radio" size=".6rem" v-if="!iconshows"></x-icon>
                          <x-icon type="ios-circle-outline" size=".6rem" v-if="iconshows"></x-icon>
                          <label for="two">按每月还款计算</label>
                    </div>
                </flexbox-item>
            </flexbox>
             <group v-if="concat">
                <x-input v-if="loanMoney" class="picker" type="number" title="贷款金额(万)" v-model="value" placeholder="请输入" ></x-input>
                <x-input class="picker-input" v-if="!loanMoney" type="number" title="每月还款(元)" v-model="value0" placeholder="请输入" ></x-input>
                <p class="error" v-show="loan0 === 0">请输入贷款金额</p>
                <p class="error" v-show="loan0 === 1">商业贷款最大金额为1亿</p>
                <p class="error" v-show="loan0 === 2">每月还款最大额度100万</p>
                <p class="error" v-show="loan0 === 3">公积金贷款最大额度120万</p>
                <popup-picker  title="贷款期限(年)" :data="homelist" v-model="value1" value-text-align="left"></popup-picker>
                <p class="error" v-show="loan0 === 4">请选择贷款期限</p>
                <popup-picker class="rate-picker" v-if="loanyearRate === 1" title="贷款年利率(%)" :data="ratelist" v-model="value2" value-text-align="left" @on-change="changerate"></popup-picker>
                <popup-picker class="rate-picker" v-if="loanyearRate === 2" title="贷款年利率(%)" :data="gjjlist" v-model="value2" value-text-align="left" @on-change="changerate"></popup-picker>
                <p class="error" v-show="loan0 === 5">请选择贷款年利率</p>
                <p class="error" v-show="loan0 === 6">请输入自定义利率</p>
                <x-input class="custom" v-if="customrate === 1" title="贷款年利率(%)" type="number" v-model="value3" placeholder="自定义基准利率(选填)" ></x-input> 
            </group>
            <div v-if="!concat" id="customloan">
                <group v-if="groupcount">
                    <popup-picker class="deadline" title="贷款期限(年)" :data="homelist" v-model="value1" value-text-align="left"></popup-picker>
                    <p class="error" v-show="loan0 === 7">请选择贷款期限</p>
                    <x-input class="picker-input" type="number" title="商业贷款(万)" v-model="value" placeholder="请输入" ></x-input>
                    <p class="error" v-show="loan0 === 8">请至少输入一个贷款金额</p>
                    <popup-picker class="rate-picker"   title="商贷利率(%)" :data="ratelist" v-model="busrate" value-text-align="left" @on-change="changeratebus"></popup-picker>
                    <x-input class="custom" v-if="ratebus === 1" title="贷款年利率(%)" type="number" v-model="zdybusloan" placeholder="自定义基准利率(选填)" ></x-input>
                    <p class="error" v-show="loan0 === 9">请至少选择一个贷款利率</p>
                    <p class="error" v-show="loan0 === 10">请至少输入一个贷款利率</p>
                    <p class="error" v-show="loan0 === 11">请至少选择或输入一个贷款利率</p>
                    <x-input  class="picker-input" type="number" title="公积金贷款(万)" v-model="gjjloan" placeholder="请输入" ></x-input>
                    <popup-picker class="rate-picker"   title="公积金利率(%)" :data="gjjlist" v-model="gjjrate" value-text-align="left" @on-change="changerategjj"></popup-picker>
                    <x-input class="custom" v-if="rategjj === 1" title="贷款年利率(%)" type="number" v-model="zdygjjloan" placeholder="自定义基准利率(选填)" ></x-input>
                </group>
                <group v-if="!groupcount" class="loanall">
                    <x-input class="picker-input monthevery" type="number" title="每月还款(元)" v-model="value0" placeholder="请输入" ></x-input>
                    <p class="error" v-show="loan0 === 12">请输入每月还款</p>
                    <popup-picker  title="贷款期限(年)" :data="homelist" v-model="value1" value-text-align="left"></popup-picker>
                    <x-input class="picker-input "  type="number" title="可贷公积金总额(万)" v-model="loanall" placeholder="请输入" ></x-input>
                    <popup-picker class="rate-picker"   title="公积金利率(%)" :data="gjjlist" v-model="gjjrate" value-text-align="left" @on-change="changeratebus"></popup-picker>
                    <x-input class="custom" v-if="customrate === 4" title="公积金利率(%)" type="number" v-model="zdygjjloan" placeholder="自定义基准利率(选填)" ></x-input>
                    <popup-picker class="rate-picker" title="商贷利率(%)" :data="ratelist" v-model="value2" value-text-align="left" @on-change="changerategjj"></popup-picker>
                    <x-input class="custom" v-if="customrate === 5" title="商贷利率(%)" type="number" v-model="value3" placeholder="自定义基准利率(选填)" ></x-input>
                </group>
            </div>
        </div>
        <flexbox class='persion-btn' v-show="startbtn === 0">
            <flexbox-item><div class='flex-demo next' @click='empty'>清空重填</div></flexbox-item>
            <flexbox-item><div class='flex-demo' @click='startFirst'>开始计算</div></flexbox-item>
        </flexbox>
       <div class="circle"></div>
       <div class="count-resoult" v-if="soult">
            <tab  :line-width="2" active-color="rgb(20,93,210)" bar-active-color="rgb(20,93,210)">
                <tab-item   selected @on-item-click="onFirst">等额本息</tab-item>
                <tab-item   @on-item-click="onSecond">等额本金</tab-item>
            </tab> 
             <x-table  style="background-color:#fff" class="table-soult">
                <tbody>
                    <tr>
                    <td>
                        贷款金额
                        <br/>
                        <span>{{money}}</span>
                        <br/>
                        <span class="small-span" v-if="small">公积金  {{gjjloanval}}</span>   
                        <span class="small-span" v-if="small">商贷  {{busloanval}}</span>
                    </td>
                    <td >
                        总利息(元)
                        <br/>
                        <span>{{interest}}</span> 
                    </td>
                    </tr>
                    <tr>
                    <td>
                        总还款(元)
                        <br/>
                        <span >{{totalplay}}</span>
                    </td>
                    <td v-if="everymonth">
                        每月还款(元)
                        <br/>
                        <span >{{everyplay}}</span>
                    </td>
                    <td v-if="!everymonth">
                        首月还款(元)
                        <br/>
                        <span >{{everyplay}}</span>
                        <br/>
                        <span class="small-span">每月递减{{decrease}}元</span>
                    </td>      
                    </tr>
                </tbody>
            </x-table>      
        </div>
    </div>
</template>
<script>
import { Tab, TabItem, Flexbox, FlexboxItem, Group, XInput, PopupPicker, TransferDom, XTable } from 'vux'
export default {
  directives: {
    TransferDom
  },
  created () {
    window.document.title = '房贷计算器'
  },
  data () {
    return {
      computeStyle: 0, // 显示商业贷款
      iconshow: true,
      iconshows: true,
      concat: true, // 显示 商业贷款 公积金贷款
      loanMoney: true, // 显示按贷款金额计算
      value: null, // 显示 商业贷款 公积金贷款 按贷款金额计算的值
      value0: null, // 显示 商业贷款 公积金贷款 按每月还款计算的值
      loan0: 100, // 判断显示
      // 贷款期限 商业贷款 公积金贷款
      homelist: [['请选择', '1年(12期)', '2年(24期)', '3年(36期)', '4年(48期)', '5年(60期)', '6年(72期)', '7年(84期)', '8年(96期)', '9年(108期)', '10年(120期)', '11年(132期)', '12年(144期)', '13年(156期)', '14年(168期)', '15年(180期)', '16年(192期)', '17年(204期)', '18年(216期)', '19年(228期)', '20年(240期)', '21年(252期)', '22年(264期)', '23年(276期)', '24年(288期)', '25年(300期)', '26年(312期)', '27(324期)', '28年(336期)', '29年(348期)', '30年(360期)']],
      value1: ['请选择'],
      // 商业贷款 贷款年利率
      ratelist: [['请选择', '基准利率(4.165%)', '基准利率(4.41%)', '基准利率(4.655%)', '基准利率(4.9%)', '基准利率(5.39%)', '基准利率(5.88%)', '自定义利率']],
      // 公积金贷款 贷款年利率
      gjjlist: [['请选择', '基准利率(3.25%)', '基准利率(3.575%)', '基准利率(3.9%)', '自定义利率']],
      value2: ['请选择'],
      loanyearRate: 1, // 选择 商业贷款 公积金贷款 年利率显示
      // 显示 商业贷款 公积金贷款  自定义年利率
      customrate: 0,
      value3: '',
      startbtn: 0, // 开始计算 商业贷款按钮
      soult: false, // 显示计算结果
      everymonth: true, // 等额本金显示首月递减
      money: null,
      interest: '',
      totalplay: '',
      everyplay: '',
      decrease: '', // 每月递减
      type: 1, // 定义切换等额本息 等额本金时候显示的结果
      loanval: 1, // 定义商业贷款金额 和公积金贷款金额判定
      groupcount: true, // 显示组合贷款 按贷款金额
      busrate: ['请选择'], // 组合 商业贷款利率
      gjjrate: ['请选择'], // 组合 公积金贷款利率
      zdybusloan: '', // 组合 自定义商业贷款利率
      zdygjjloan: '', // 组合 自定义公积金贷款利率
      gjjloan: '', // 组合 公积金贷款金额
      loanall: '', // 组合 公积金贷款总金额
      ratebus: 0,
      rategjj: 0,
      small: false,
      gjjloanval: '', // 组合 贷款金额 小字
      busloanval: ''
    }
  },
  components: {
    Tab,
    TabItem,
    Flexbox,
    FlexboxItem,
    Group,
    XInput,
    PopupPicker,
    XTable
  },
  methods: {
    empty () {
      this.busrate = ['请选择']
      this.gjjrate = ['请选择']
      this.zdybusloan = ''
      this.zdygjjloan = ''
      this.gjjloan = ''
      this.loanall = ''
      this.loan0 = 100
      this.defined()
    },
    onItemClick (index) { // 切换 商业 公积金 组合
      if (index === 0) { // 商业
        this.type = 1
        this.loan0 = 100
        this.customrate = 0
        this.concat = true // 显示 商业贷款
        this.loanMoney = true // 显示按贷款金额计算
        this.iconshow = true
        this.iconshows = true
        this.loanval = 1
        this.loanyearRate = 1 // 商业贷款年利率
        this.defined()
      }
      if (index === 1) { // 公积金
        this.type = 1
        this.loan0 = 100
        this.customrate = 0
        this.concat = true // 显示  公积金贷款
        this.loanMoney = true // 显示按贷款金额计算
        this.iconshow = true
        this.iconshows = true
        this.loanval = 2
        this.loanyearRate = 2 // 公积金贷款年利率
        this.defined()
      }
      if (index === 2) { // 组合
        this.type = 1
        this.loan0 = 100
        this.customrate = 0
        this.concat = false
        this.groupcount = true
        this.iconshow = true
        this.iconshows = true
        this.busrate = ['请选择']
        this.zdybusloan = ''
        this.gkkrate = ['请选择']
        this.loanall = ''
        this.defined()
      }
    },
    defined () {
      this.value = ''
      this.value0 = ''
      this.value1 = ['请选择']
      this.value2 = ['请选择']
      this.value3 = ''
      this.soult = false
      this.small = false
      this.money = ''
      this.interest = ''
      this.totalplay = ''
      this.everyplay = ''
      this.decrease = ''
    },
    businessFirst () { // 商业 按贷款金额计算
      this.everymonth = true  // 切换显示
      this.iconshow = true
      this.iconshows = true
      this.loanMoney = true // 显示按贷款金额计算
      this.type = 1
      this.defined()
      if (this.concat === false) {
        this.groupcount = true // 组合 判断 按贷款金额
      }
    },
    businessSecond () { // 商业 按每月还款计算
      this.everymonth = true // 切换显示
      this.iconshows = false
      this.iconshow = false
      this.loanMoney = false // 显示按每月还款计算
      this.type = 1
      this.defined()
      if (this.concat === false) {
        this.groupcount = false // 组合 判断 按每月还款
      }
    },
    changerate (val) { // 商业贷款年利率 公积金贷款年利率 的值
      if (val[0] === '自定义利率') {
        this.customrate = 1
      } else {
        this.customrate = 0
      }
    },
    changeratebus (val) {
      if (val[0] === '自定义利率') {
        this.ratebus = 1
      } else {
        this.ratebus = 0
      }
    },
    changerategjj (val) {
      if (val[0] === '自定义利率') {
        this.rategjj = 1
      } else {
        this.rategjj = 0
      }
    },
    // 等额本息 切换按钮
    onFirst () {
      this.everymonth = true
      this.type = 1  // 定义按开始计算按钮时显示等额本息结果
      if (this.value !== '' && this.value1[0] !== '请选择' && this.concat === true && this.loanMoney === true) {
        this.businessdebx() // 按贷款金额计算
      }
      if (this.value0 !== '' && this.value1[0] !== '请选择' && this.concat === true && this.loanMoney === false) {
        this.monthdebx() // 按贷款金额计算
      }
      if (this.concat === false && this.groupcount === true) {
        this.small = false
        if (this.value1[0] !== '请选择') {
          if (this.busrate[0] !== '请选择' && this.value !== '') { // 组合 商业 按贷款金额
            if (this.gjjrate[0] === '请选择' || this.gjjloan === '' || this.zdygjjloan === '') {
              this.zhbusdebx()
            }
          }
          if (this.gjjrate[0] !== '请选择' && this.gjjloan !== '') {
            if (this.busrate[0] === '请选择' || this.value === '' || this.zdybusloan === '') {
              this.zhgjjdebx()
            }
          }
          if (this.busrate[0] !== '请选择' && this.value !== '' && this.gjjloan !== '' && this.gjjrate[0] !== '请选择') {
            this.loansum()
          }
        }
      }
      if (this.groupcount === false && this.concat === false) {
        this.small = true
        if (this.value0 !== '' && this.value1[0] !== '请选择') {
          this.loansummonth()
        }
      }
    },
    onSecond () { // 等额本金 切换按钮
      this.everymonth = false
      this.type = 2  // 定义按开始计算按钮时显示等额本金结果
      if (this.concat === true && this.groupcount === true) {
        if (this.value !== '' && this.value1[0] !== '请选择' && this.loanMoney === true) {
          this.businessdebj()
        }
        if (this.loanMoney === false && this.value0 !== '' && this.value1[0] !== '请选择') {
          this.monthdebj()
        }
      }
      if (this.concat === false && this.groupcount === true) {
        this.small = false
        this.zhdebj()
      }
      if (this.groupcount === false && this.concat === false) {
        if (this.value0 !== '' && this.value1[0] !== '请选择') {
          this.zhmonthdebj()
        }
      }
    },
    // ------------------------------------------------------------------------------商业贷款开始计算-----------------------------------------//
    startFirst () {
      if (this.loanMoney === true && this.concat === true) {
        if (this.value === '') {
          this.loan0 = 0
          this.soult = false
        } else if (this.value1[0] === '请选择') {
          this.loan0 = 4
          this.soult = false
        } else if (this.value2[0] === '请选择') {
          this.loan0 = 5
          this.soult = false
        } else if (this.value > 10000) {
          this.loan0 = 1
          this.soult = false
        } else if (this.value2[0] === '自定义利率' && this.value3 === '') {
          this.loan0 = 6
          this.soult = false
        } else if (this.value !== '' && this.value1[0] !== '请选择' && this.loanMoney === true && this.concat === true) {
          if (this.type === 1) {
            this.everymonth = true
            this.businessdebx()
          } else if (this.type === 2) {
            this.everymonth = false
            this.businessdebj()
          }
        }
        if (this.loanMoney === true && this.loanval === 2) {
          if (this.value > 120) {
            this.loan0 = 3
            this.soult = false
          }
        }
      }
      if (this.loanMoney === false && this.concat === true) {
        if (this.value0 === '') {
          this.loan0 = 0
          this.soult = false
        } else if (this.value1[0] === '请选择') {
          this.loan0 = 4
          this.soult = false
        } else if (this.value2[0] === '请选择') {
          this.loan0 = 5
          this.soult = false
        } else if (this.value0 > 1000000) {
          this.loan0 = 2
          this.soult = false
        } else if (this.value2[0] === '自定义利率' && this.value3 === '') {
          this.loan0 = 6
          this.soult = false
        } else if (this.value0 !== '' && this.value1[0] !== '请选择') {
          if (this.type === 1) {
            this.everymonth = true
            this.monthdebx()
          } else if (this.type === 2) {
            this.everymonth = false
            this.monthdebj()
          }
        }
      }
      if (this.groupcount === true && this.concat === false) {
        if (this.value1[0] === '请选择') {
          this.loan0 = 7
          this.soult = false
        } else if (this.value === '' && this.gjjloan === '') {
          this.loan0 = 8
          this.soult = false
        } else if (this.busrate[0] === '请选择' && this.gjjrate[0] === '请选择') {
          this.loan0 = 9
          this.soult = false
        } else if (this.busrate[0] === '请选择' && this.gjjrate[0] === '自定义利率' && this.zdygjjloan === '') {
          this.loan0 = 10
          this.soult = false
        } else if (this.gjjrate[0] === '请选择' && this.busrate[0] === '自定义利率' && this.zdybusloan === '') {
          this.loan0 = 10
          this.soult = false
        } else if (this.zdygjjloan === '' && this.zdybusloan === '' && this.busrate[0] === '自定义利率' && this.gjjrate[0] === '自定义利率') {
          this.loan0 = 11
          this.soult = false
        }
        if (this.value1[0] !== '请选择' && this.type === 1) {
          if (this.busrate[0] !== '请选择' && this.value !== '') {
            // 组合 商业 按贷款金额
            if (this.gjjrate[0] === '请选择' || this.gjjloan === '' || this.zdygjjloan === '') {
              this.zhbusdebx()
            }
          }
          if (this.gjjrate[0] !== '请选择' && this.gjjloan !== '') {
            if (this.busrate[0] === '请选择' || this.value === '' || this.zdybusloan === '') {
              this.zhgjjdebx()
            }
          }
          if (this.busrate[0] !== '请选择' && this.value !== '' && this.gjjloan !== '' && this.gjjrate[0] !== '请选择') {
            this.loansum()
          }
        }
        if (this.type === 2 && this.value1[0] !== '请选择') {
          this.zhdebj()
        }
      }
      if (this.groupcount === false && this.concat === false) {
        if (this.value0 === '') {
          this.loan0 = 12
          this.soult = false
        } else if (this.value1[0] === '请选择') {
          this.loan0 = 13
          this.soult = false
        }
        if (this.value0 !== '' && this.value1[0] !== '请选择' && this.type === 1) {
          this.loansummonth()
        }
        if (this.value0 !== '' && this.value1[0] !== '请选择' && this.type === 2) {
          this.zhmonthdebj()
        }
      }
    },
    // ----------------------------------等额本息---------------------------------------------------------------//
    // 商业贷款 公积金贷款  按贷款金额计算  等额本息
    businessdebx () {
      var loanmoney = this.value * 10000 // 贷款金额
      var loantime = this.value1[0]
      loantime = parseFloat(loantime) * 12 // 贷款期限
      var loanrate1 = this.value2[0].slice(5)
      loanrate1 = parseFloat(loanrate1) // 贷款年利率 （选择）
      var loanrate2 = this.value3
      loanrate2 = parseFloat(loanrate2) // 贷款年利率（自定义）
      this.money = loanmoney.toFixed(2) // 显示的贷款金额
      if (this.value2[0] !== '请选择' && this.value2[0] !== '自定义利率') {
        this.loan0 = 100
        this.soult = true // 等额本息
        var monthrate = loanrate1 / (12 * 100) // 月利率
        var monthrefund = (loanmoney * monthrate * Math.pow((1 + monthrate), loantime)) / (Math.pow((1 + monthrate), loantime) - 1) // 月均还款
        this.totalplay = (monthrefund * loantime).toFixed(2) // 还款总额
        this.everyplay = monthrefund.toFixed(2) // 每月还款
        this.interest = (this.totalplay - this.money).toFixed(2) // 总利息
      }
      if (this.value2[0] === '自定义利率') {
        this.loan0 = 100
        this.soult = true // 自定义 等额本息
        var monthrateZ = loanrate2 / (12 * 100) // 月利率
        var monthrefundZ = (loanmoney * monthrateZ * Math.pow((1 + monthrateZ), loantime)) / (Math.pow((1 + monthrateZ), loantime) - 1) // 月均还款
        this.totalplay = (monthrefundZ * loantime).toFixed(2) // 还款总额
        this.everyplay = monthrefundZ.toFixed(2) // 每月还款
        this.interest = (this.totalplay - this.money).toFixed(2) // 总利息
      }
    },
    businessdebj () { // 商业贷款 公积金贷款  按贷款金额计算  等额本金
      var loanmoney = this.value * 10000 // 贷款金额
      var loantime = this.value1[0]
      loantime = parseFloat(loantime) * 12 // 贷款期限
      var loanrate1 = this.value2[0].slice(5)
      loanrate1 = parseFloat(loanrate1) // 贷款年利率 （选择）
      var loanrate2 = this.value3
      loanrate2 = parseFloat(loanrate2) // 贷款年利率（自定义）
      var monthbj = loanmoney / loantime // 每月本金
      this.money = loanmoney.toFixed(2) // 显示的贷款金额
      if (this.value2[0] !== '自定义利率' && this.value2[0] !== '请选择') {
        var rate = (loantime + 1) * loanmoney * (loanrate1 / 1200) / 2 // 总利息
        this.interest = rate.toFixed(2)
        var total = rate + loanmoney
        this.totalplay = total.toFixed(2) // 总还款
        var monthevery = loanmoney / loantime + loanmoney * (loanrate1 / 1200)
        this.everyplay = monthevery.toFixed(2) // 每月还款
        var decreased = monthbj * (loanrate1 / 1200)
        this.decrease = decreased.toFixed(2) // 每月递减
      }
      if (this.value2[0] === '自定义利率' && this.value3 !== '') {
        var rateZ = (loantime + 1) * loanmoney * (loanrate2 / 1200) / 2 // 总利息
        this.interest = rateZ.toFixed(2)
        var totalZ = rateZ + loanmoney
        this.totalplay = totalZ.toFixed(2) // 总还款
        var montheveryZ = loanmoney / loantime + loanmoney * (loanrate2 / 1200)
        this.everyplay = montheveryZ.toFixed(2) // 每月还款
        var decreasedZ = monthbj * (loanrate2 / 1200)
        this.decrease = decreasedZ.toFixed(2) // 每月递减
      }
    },
    monthdebx () { // 商业贷款 公积金贷款  按每月还款计算  等额本息
      var loantime = this.value1[0]
      loantime = parseFloat(loantime) * 12 // 贷款期限
      var loanrate1 = this.value2[0].slice(5)
      loanrate1 = parseFloat(loanrate1) // 贷款年利率 （选择）
      var loanrate2 = this.value3
      loanrate2 = parseFloat(loanrate2) // 贷款年利率（自定义）
      var money0 = parseFloat(this.value0)
      if (this.value2[0] !== '请选择' && this.value2[0] !== '自定义利率') {
        this.soult = true // 每月还款数 选择利率
        this.loan0 = 100
        var monthrate = Math.pow((1 + loanrate1 / 1200), loantime)
        var money = (money0 * (monthrate - 1)) / ((loanrate1 / 1200) * monthrate)
        this.money = money.toFixed(2) // 贷款金额
        var totals = money0 * loantime // 总还款
        this.totalplay = totals.toFixed(2)
        this.interest = (this.totalplay - this.money).toFixed(2) // 总利息
        this.everyplay = money0.toFixed(2)
        this.busloanval = this.money
        this.gjjloanval = '0.00'
      }
      if (this.value2[0] === '自定义利率') {
        this.soult = true
        this.loan0 = 100 // 每月还款 自定义利率
        var monthratez = Math.pow((1 + loanrate2 / 1200), loantime)
        var moneyZ = (money0 * (monthratez - 1)) / ((loanrate2 / 1200) * monthratez)
        this.money = moneyZ.toFixed(2) // 贷款金额
        var totalsZ = money0 * loantime // 总还款
        this.totalplay = totalsZ.toFixed(2)
        this.interest = (this.totalplay - this.money).toFixed(2) // 总利息
        this.everyplay = money0.toFixed(2)
        this.busloanval = this.money
        this.gjjloanval = '0.00'
      }
    },
    monthdebj () { // 商业贷款 公积金贷款  按每月还款计算  等额本金
      var loantime = this.value1[0]
      loantime = parseFloat(loantime) * 12 // 贷款期限
      var loanrate1 = this.value2[0].slice(5)
      loanrate1 = parseFloat(loanrate1) // 贷款年利率 （选择）
      var loanrate2 = this.value3
      loanrate2 = parseFloat(loanrate2) // 贷款年利率（自定义）
      var money0 = parseFloat(this.value0)
      var monthrate = Math.pow((1 + loanrate1 / 1200), loantime)
      var monthrateZ = Math.pow((1 + loanrate2 / 1200), loantime)
      var money = (money0 * (monthrate - 1)) / ((loanrate1 / 1200) * monthrate)
      var moneyZ = (money0 * (monthrateZ - 1)) / ((loanrate2 / 1200) * monthrateZ)
      console.log(money0, monthrateZ, loanrate2)
      if (this.value2[0] !== '请选择' && this.value2[0] !== '自定义利率') {
        this.money = money.toFixed(2) // 贷款金额
        var min = ((money / loantime) + (money - 0) * (loanrate1 / 1200)) - ((money / loantime) + (money - money / loantime) * (loanrate1 / 1200)) // 每月递减
        var rate = loantime * min + loantime * (loantime - 1) / 2 * min // 总利息
        this.interest = rate.toFixed(2) // 总利息
        var total = rate + money
        this.everyplay = money0.toFixed(2) // 每月本金
        this.totalplay = total.toFixed(2) // 总还款额
        this.decrease = min.toFixed(2) // 每月递减
      }
      if (this.value2[0] === '自定义利率') {
        this.money = moneyZ.toFixed(2) // 贷款金额
        var minZ = ((moneyZ / loantime) + (moneyZ - 0) * (loanrate2 / 1200)) - ((moneyZ / loantime) + (moneyZ - moneyZ / loantime) * (loanrate2 / 1200)) // 每月递减
        var Zrate = loantime * minZ + loantime * (loantime - 1) / 2 * minZ // 总利息
        this.interest = Zrate.toFixed(2) // 总利息
        var totalZ = Zrate + moneyZ
        this.everyplay = money0.toFixed(2) // 每月本金
        this.totalplay = totalZ.toFixed(2) // 总还款额
        this.decrease = minZ.toFixed(2) // 每月递减
      }
    },
    zhbusdebx () { // 组合贷款  按贷款金额计算 商业的  等额本息
      var loanmoney = this.value * 10000 // 贷款金额
      var loantime = this.value1[0]
      loantime = parseFloat(loantime) * 12 // 贷款期限
      var loanrate1 = this.busrate[0].slice(5)
      loanrate1 = parseFloat(loanrate1) // 贷款年利率 （选择）
      var loanrate2 = this.zdybusloan
      loanrate2 = parseFloat(loanrate2) // 贷款年利率（自定义）
      this.money = loanmoney.toFixed(2) // 显示的贷款金额
      if (this.busrate[0] !== '自定义利率') {
        this.loan0 = 100
        this.soult = true // 等额本息
        var monthrate = loanrate1 / (12 * 100) // 月利率
        var monthrefund = (loanmoney * monthrate * Math.pow((1 + monthrate), loantime)) / (Math.pow((1 + monthrate), loantime) - 1) // 月均还款
        this.totalplay = (monthrefund * loantime).toFixed(2) // 还款总额
        this.everyplay = monthrefund.toFixed(2) // 每月还款
        this.interest = (this.totalplay - this.money).toFixed(2) // 总利息
      }
      if (this.busrate[0] === '自定义利率') {
        this.loan0 = 100
        this.soult = true // 等额本息
        var Zmonthrate = loanrate2 / (12 * 100) // 月利率
        var Zmonthrefund = (loanmoney * Zmonthrate * Math.pow((1 + Zmonthrate), loantime)) / (Math.pow((1 + Zmonthrate), loantime) - 1) // 月均还款
        this.totalplay = (Zmonthrefund * loantime).toFixed(2) // 还款总额
        this.everyplay = Zmonthrefund.toFixed(2) // 每月还款
        this.interest = (this.totalplay - this.money).toFixed(2) // 总利息
      }
    },
    zhgjjdebx () { // 组合贷款  按贷款金额计算 公积金的  等额本息
      var loanmoney = this.gjjloan * 10000 // 贷款金额
      var loantime = this.value1[0]
      loantime = parseFloat(loantime) * 12 // 贷款期限
      var loanrate1 = this.gjjrate[0].slice(5)
      loanrate1 = parseFloat(loanrate1) // 贷款年利率 （选择）
      var loanrate2 = this.zdygjjloan
      loanrate2 = parseFloat(loanrate2) // 贷款年利率（自定义）
      this.money = loanmoney.toFixed(2) // 显示的贷款金额
      if (this.gjjrate[0] !== '自定义利率') {
        this.loan0 = 100
        this.soult = true // 等额本息
        var monthrate = loanrate1 / (12 * 100) // 月利率
        var monthrefund = (loanmoney * monthrate * Math.pow((1 + monthrate), loantime)) / (Math.pow((1 + monthrate), loantime) - 1) // 月均还款
        this.totalplay = (monthrefund * loantime).toFixed(2) // 还款总额
        this.everyplay = monthrefund.toFixed(2) // 每月还款
        this.interest = (this.totalplay - this.money).toFixed(2) // 总利息
      }
      if (this.gjjrate[0] === '自定义利率') {
        this.loan0 = 100
        this.soult = true // 等额本息
        var monthrateZ = loanrate2 / (12 * 100) // 月利率
        var monthrefundZ = (loanmoney * monthrateZ * Math.pow((1 + monthrateZ), loantime)) / (Math.pow((1 + monthrateZ), loantime) - 1) // 月均还款
        this.totalplay = (monthrefundZ * loantime).toFixed(2) // 还款总额
        this.everyplay = monthrefundZ.toFixed(2) // 每月还款
        this.interest = (this.totalplay - this.money).toFixed(2) // 总利息
      }
    },
    loansum () { // 组合贷款  按贷款金额计算 公积金+商业之和  等额本息
      var loanmoneygjj = this.gjjloan * 10000 // 贷款金额
      var loanmoneybus = this.value * 10000 // 贷款金额
      var loantime = this.value1[0]
      loantime = parseFloat(loantime) * 12 // 贷款期限
      var loanrate1gjj = this.gjjrate[0].slice(5)
      loanrate1gjj = parseFloat(loanrate1gjj) // 贷款年利率 （选择）
      var loanrate2gjj = this.zdygjjloan
      loanrate2gjj = parseFloat(loanrate2gjj) // 贷款年利率（自定义）
      var loanrate1bus = this.busrate[0].slice(5)
      loanrate1bus = parseFloat(loanrate1bus) // 贷款年利率 （选择）
      var loanrate2bus = this.zdybusloan
      loanrate2bus = parseFloat(loanrate2bus) // 贷款年利率（自定义）
      this.money = (loanmoneygjj + loanmoneybus).toFixed(2) // 显示的贷款金额
      if (this.busrate[0] !== '自定义利率' && this.gjjrate[0] !== '自定义利率') {
        this.loan0 = 100
        this.soult = true // 等额本息
        var monthratebus = loanrate1bus / (12 * 100) // 月利率
        var monthrefundbus = (loanmoneybus * monthratebus * Math.pow((1 + monthratebus), loantime)) / (Math.pow((1 + monthratebus), loantime) - 1) // 月均还款
        var totalplaybus = (monthrefundbus * loantime)// 还款总额
        var everyplaybus = monthrefundbus // 每月还款
        var interestbus = (totalplaybus - loanmoneybus) // 总利息
        // 等额本息
        var monthrategjj = loanrate1gjj / (12 * 100) // 月利率
        var monthrefundgjj = (loanmoneygjj * monthrategjj * Math.pow((1 + monthrategjj), loantime)) / (Math.pow((1 + monthrategjj), loantime) - 1)
        var totalplaygjj = (monthrefundgjj * loantime)
        var everyplaygjj = monthrefundgjj // 每月还款
        var interestgjj = (totalplaygjj - loanmoneygjj) // 总利息
        this.totalplay = (totalplaybus + totalplaygjj).toFixed(2) // 还款总额
        this.everyplay = (everyplaybus + everyplaygjj).toFixed(2) // 每月还款
        this.interest = (interestbus + interestgjj).toFixed(2) // 总利息
      }
      if (this.busrate[0] === '自定义利率' && this.gjjrate[0] === '自定义利率') {
        this.loan0 = 100
        this.soult = true // 等额本息
        var monthratebusZ = loanrate2bus / (12 * 100) // 月利率
        var monthrefundbusZ = (loanmoneybus * monthratebusZ * Math.pow((1 + monthratebusZ), loantime)) / (Math.pow((1 + monthratebusZ), loantime) - 1) // 月均还款
        var totalplaybusZ = (monthrefundbusZ * loantime) // 还款总额
        var everyplaybusZ = monthrefundbusZ // 每月还款
        var interestbusZ = (totalplaybusZ - loanmoneybus) // 总利息
        // 自定义 等额本息
        var monthrategjjZ = loanrate2gjj / (12 * 100) // 月利率
        var monthrefundgjjZ = (loanmoneygjj * monthrategjjZ * Math.pow((1 + monthrategjjZ), loantime)) / (Math.pow((1 + monthrategjjZ), loantime) - 1) // 月均还款
        var totalplaygjjZ = (monthrefundgjjZ * loantime) // 还款总额
        var everyplaygjjZ = monthrefundgjjZ // 每月还款
        var interestgjjZ = (totalplaygjjZ - loanmoneygjj) // 总利息
        this.totalplay = (totalplaybusZ + totalplaygjjZ).toFixed(2)
        this.everyplay = (everyplaybusZ + everyplaygjjZ).toFixed(2)
        this.interest = (interestbusZ + interestgjjZ).toFixed(2)
      }
      if (this.busrate[0] === '自定义利率' && this.gjjrate[0] !== '自定义利率') {
        this.loan0 = 100
        this.soult = true // 自定义 等额本息
        var Monthratebus = loanrate2bus / (12 * 100) // 月利率
        var Monthrefundbus = (loanmoneybus * Monthratebus * Math.pow((1 + monthratebus), loantime)) / (Math.pow((1 + monthratebus), loantime) - 1) // 月均还款
        var Totalplaybus = (Monthrefundbus * loantime) // 还款总额
        var Everyplaybus = monthrefundbus // 每月还款
        var Interestbus = (Totalplaybus - loanmoneybus) // 总利息
        var Monthrategjj = loanrate1gjj / (12 * 100)  // 月利率
        var Monthrefundgjj = (loanmoneygjj * Monthrategjj * Math.pow((1 + Monthrategjj), loantime)) / (Math.pow((1 + Monthrategjj), loantime) - 1)
        var Totalplaygjj = (Monthrefundgjj * loantime)
        var Everyplaygjj = Monthrefundgjj // 每月还款
        var Interestgjj = (Totalplaygjj - loanmoneygjj) // 总利息
        this.totalplay = (Totalplaybus + Totalplaygjj).toFixed(2)
        this.everyplay = (Everyplaybus + Everyplaygjj).toFixed(2)
        this.interest = (Interestbus + Interestgjj).toFixed(2)
      }
      if (this.busrate[0] !== '自定义利率' && this.gjjrate[0] === '自定义利率') {
        this.loan0 = 100
        this.soult = true // 等额本息
        var monthRatebus = loanrate1bus / (12 * 100) // 月利率
        var monthRefundbus = (loanmoneybus * monthRatebus * Math.pow((1 + monthRatebus), loantime)) / (Math.pow((1 + monthRatebus), loantime) - 1) // 月均还款
        var totalPlaybus = (monthRefundbus * loantime) // 还款总额
        var everyPlaybus = monthRefundbus // 每月还款
        var interestBus = (totalPlaybus - loanmoneybus) // 总利息
        // 自定义
        var monthRategjj = loanrate2gjj / (12 * 100) // 月利率
        var monthRefundgjj = (loanmoneygjj * monthRategjj * Math.pow((1 + monthRategjj), loantime)) / (Math.pow((1 + monthRategjj), loantime) - 1) // 月均还款
        var totalPlaygjj = (monthRefundgjj * loantime) // 还款总额
        var everyPlaygjj = monthRefundgjj // 每月还款
        var interestGjj = (totalPlaygjj - loanmoneygjj) // 总利息
        this.totalplay = (totalPlaybus + totalPlaygjj).toFixed(2)
        this.everyplay = (everyPlaybus + everyPlaygjj).toFixed(2)
        this.interest = (interestBus + interestGjj).toFixed(2)
      }
    },
    loansummonth () { // 组合贷款  按每月还款计算  等额本息
      if (this.loanall === '') {
        this.small = true
        this.monthdebx()
        this.show = true
      }
      if (this.loanall !== '') {
        var loantime = this.value1[0]
        loantime = parseFloat(loantime) * 12 // 贷款期限
        var loanrate1 = this.gjjrate[0].slice(5)
        loanrate1 = parseFloat(loanrate1) // 贷款年利率 （选择）
        var loanrate2 = this.gjjrate
        loanrate2 = parseFloat(loanrate2) // 贷款年利率（自定义）
        var money0 = parseFloat(this.value0)
        if (this.gjjrate[0] !== '请选择' && this.zdygjjloan === '') {
          this.small = true
          this.soult = true
          this.loan0 = 100
          // 每月还款数 选择利率
          var monthrate = Math.pow((1 + loanrate1 / 1200), loantime)
          var money = (money0 * (monthrate - 1)) / ((loanrate1 / 1200) * monthrate)
          this.money = money.toFixed(2) // 贷款金额
          this.busloanval = '0.00'
          this.gjjloanval = this.money
          var totals = money0 * loantime // 总还款
          this.totalplay = totals.toFixed(2)
          this.interest = (this.totalplay - this.money).toFixed(2) // 总利息
          this.everyplay = money0.toFixed(2)
        }
        if (this.gjjrate[0] === '自定义利率') {
          this.soult = true
          this.loan0 = 100
          this.show = true
          // 每月还款 自定义利率
          var MonthRate = Math.pow((1 + loanrate2 / 1200), loantime)
          var Money = (money0 * (MonthRate - 1)) / ((loanrate2 / 1200) * MonthRate)
          this.money = Money.toFixed(2) // 贷款金额
          this.busloanval = '0.00'
          this.gjjloanval = this.money
          var Totals = money0 * loantime // 总还款
          this.totalplay = Totals.toFixed(2)
          this.interest = (this.totalplay - this.money).toFixed(2) // 总利息
          this.everyplay = money0.toFixed(2)
        }
      }
    },
    zhdebj () { // 组合贷款  按贷款金额计算  等额本金
      this.loan0 = 100
      this.small = false
      this.soult = true
      if (this.value === '' || this.busrate[0] === '请选择' || this.busrate[0] === '自定义利率') {
        // 公积金
        var loanmoney = this.gjjloan * 10000 // 贷款金额
        var loantime = this.value1[0]
        loantime = parseFloat(loantime) * 12 // 贷款期限
        var loanrate1 = this.gjjrate[0].slice(5)
        loanrate1 = parseFloat(loanrate1) // 贷款年利率 （选择）
        var loanrate2 = this.zdygjjloan
        loanrate2 = parseFloat(loanrate2) // 贷款年利率（自定义）
        var monthbj = loanmoney / loantime // 每月本金
        if (this.gjjrate[0] !== '自定义利率' && this.gjjloan !== '' && this.gjjrate[0] !== '请选择') {
          var rate = (loantime + 1) * loanmoney * (loanrate1 / 1200) / 2 // 总利息
          this.interest = rate.toFixed(2)
          var total = rate + loanmoney
          this.totalplay = total.toFixed(2) // 总还款
          var monthevery = loanmoney / loantime + loanmoney * (loanrate1 / 1200)
          this.everyplay = monthevery.toFixed(2) // 每月还款
          var decreased = monthbj * (loanrate1 / 1200)
          this.decrease = decreased.toFixed(2) // 每月递减
          this.money = loanmoney.toFixed(2) // 显示的贷款金额
        }
        if (this.gjjrate[0] === '自定义利率' && this.gjjloan !== '') {
          var Rate = (loantime + 1) * loanmoney * (loanrate2 / 1200) / 2 // 总利息
          this.interest = Rate.toFixed(2)
          var Total = Rate + loanmoney
          this.totalplay = Total.toFixed(2) // 总还款
          var monthEvery = loanmoney / loantime + loanmoney * (loanrate2 / 1200)
          this.everyplay = monthEvery.toFixed(2) // 每月还款
          var Decreased = monthbj * (loanrate2 / 1200)
          this.decrease = Decreased.toFixed(2) // 每月递减
          this.money = loanmoney.toFixed(2) // 显示的贷款金额
        }
      }
      if (this.gjjloan === '' || this.gjjrate[0] === '请选择' || this.gjjrate[0] === '自定义利率' || this.zdygjjloan === '') {
        var Loanmoney = this.value * 10000 // 贷款金额
        var Loantime = this.value1[0]
        Loantime = parseFloat(Loantime) * 12 // 贷款期限
        var loanRate1 = this.busrate[0].slice(5)
        loanRate1 = parseFloat(loanRate1) // 贷款年利率 （选择）
        var Loanrate2 = this.zdybusloan
        Loanrate2 = parseFloat(Loanrate2) // 贷款年利率（自定义）
        var Monthbj = Loanmoney / Loantime
        if (this.busrate[0] !== '自定义利率' && this.busrate[0] !== '请选择' && this.value !== '') {
          var RateZ = (Loantime + 1) * Loanmoney * (loanRate1 / 1200) / 2 // 总利息
          console.log(loanRate1, Loantime, 1)
          this.interest = RateZ.toFixed(2)
          var TotalZ = RateZ + Loanmoney
          this.totalplay = TotalZ.toFixed(2) // 总还款
          console.log(RateZ, 1)
          var MonthEvery = Loanmoney / Loantime + Loanmoney * (loanRate1 / 1200)
          this.everyplay = MonthEvery.toFixed(2) // 每月还款
          console.log(RateZ, 1)
          this.money = Loanmoney.toFixed(2) // 显示的贷款金额
          var DecreasedZ = Monthbj * (loanRate1 / 1200)
          this.decrease = DecreasedZ.toFixed(2) // 每月递减
        }
        if (this.busrate[0] === '自定义利率' && this.value !== '') {
          var Arate = (Loantime + 1) * Loanmoney * (Loanrate2 / 1200) / 2 // 总利息
          this.interest = Arate.toFixed(2)
          var Atotal = Arate + Loanmoney
          this.totalplay = Atotal.toFixed(2) // 总还款
          var Amonthevery = Loanmoney / Loantime + Loanmoney * (Loanrate2 / 1200)
          this.everyplay = Amonthevery.toFixed(2) // 每月还款
          this.money = Loanmoney.toFixed(2) // 显示的贷款金额
          var Adecreased = Monthbj * (Loanrate2 / 1200)
          this.decrease = Adecreased.toFixed(2) // 每月递减
        }
      }
      // 相加
      if (this.gjjloan !== '' && this.value !== '' && this.value1[0] !== '请选择') {
        var loanmoneybus = this.value * 10000 // 贷款金额
        var loanTime = this.value1[0]
        loanTime = parseFloat(loanTime) * 12 // 贷款期限
        var loanrate1bus = this.busrate[0].slice(5)
        loanrate1bus = parseFloat(loanrate1bus) // 贷款年利率 （选择）
        var loanrate2bus = this.zdybusloan
        loanrate2bus = parseFloat(loanrate2bus) // 贷款年利率（自定义）
        var loanmoneygjj = this.gjjloan * 10000 // 贷款金额
        var loanrate1gjj = this.gjjrate[0].slice(5)
        loanrate1gjj = parseFloat(loanrate1gjj) // 贷款年利率 （选择）
        var loanrate2gjj = this.zdygjjloan
        loanrate2gjj = parseFloat(loanrate2gjj) // 贷款年利率（自定义）
        var monthbjbus = loanmoneybus / loanTime
        var monthbjgjj = loanmoneygjj / loanTime  // 月还本金和
        this.money = loanmoneybus + loanmoneygjj
        if (this.gjjrate[0] !== '自定义利率' && this.busrate[0] !== '自定义利率' && this.gjjrate[0] !== '请选择' && this.busrate[0] !== '请选择') {
          var ratebus = (loanTime + 1) * loanmoneybus * (loanrate1bus / 1200) / 2
          var totalbus = ratebus + loanmoneybus
          var montheverybus = loanmoneybus / loanTime + loanmoneybus * (loanrate1bus / 1200)
          var rategjj = (loanTime + 1) * loanmoneygjj * (loanrate1gjj / 1200) / 2
          var totalgjj = rategjj + loanmoneygjj
          var montheverygjj = loanmoneygjj / loanTime + loanmoneygjj * (loanrate1gjj / 1200)
          var Btotal = totalbus + totalgjj
          this.totalplay = Btotal.toFixed(2) // 总还款
          var Bmonthevery = montheverybus + montheverygjj
          this.everyplay = Bmonthevery.toFixed(2) // 每月还款
          var Brate = ratebus + rategjj
          this.interest = Brate.toFixed(2)
          var Bdecreased = monthbjbus * (loanrate1bus / 1200) + monthbjgjj * (loanrate1gjj / 1200)
          this.decrease = Bdecreased.toFixed(2) // 每月递减
        }
        if (this.gjjrate[0] === '自定义利率' && this.busrate[0] === '自定义利率') {
          var Cratebus = (loanTime + 1) * loanmoneybus * (loanrate2bus / 1200) / 2
          var Ctotalbus = Cratebus + loanmoneybus
          var Cmontheverybus = loanmoneybus / loanTime + loanmoneybus * (loanrate2bus / 1200)
          var Crategjj = (loanTime + 1) * loanmoneygjj * (loanrate2gjj / 1200) / 2
          var Ctotalgjj = Crategjj + loanmoneygjj
          var Cmontheverygjj = loanmoneygjj / loanTime + loanmoneygjj * (loanrate2gjj / 1200)
          var Ctotal = Ctotalbus + Ctotalgjj
          this.totalplay = Ctotal.toFixed(2) // 总还款
          var Cmonthevery = Cmontheverybus + Cmontheverygjj
          this.everyplay = Cmonthevery.toFixed(2) // 每月还款
          var Crate = Cratebus + Crategjj
          this.interest1 = Crate.toFixed(2)
          var Cdecreased = monthbjbus * (loanrate2bus / 1200) + monthbjgjj * (loanrate2gjj / 1200)
          this.decrease = Cdecreased.toFixed(2) // 每月递减
        }
        if (this.gjjrate[0] === '自定义利率' && this.busrate[0] !== '自定义利率' && this.busrate[0] !== '请选择') {
          var Fratebus = (loanTime + 1) * loanmoneybus * (loanrate1bus / 1200) / 2
          var Ftotalbus = Fratebus + loanmoneybus
          var Fmontheverybus = loanmoneybus / loanTime + loanmoneybus * (loanrate1bus / 1200)
          var Frategjj = (loanTime + 1) * loanmoneygjj * (loanrate2gjj / 1200) / 2
          var Ftotalgjj = rategjj + loanmoneygjj
          var Fmontheverygjj = loanmoneygjj / loanTime + loanmoneygjj * (loanrate2gjj / 1200)
          var Ftotal = Ftotalbus + Ftotalgjj
          this.totalplay = Ftotal.toFixed(2) // 总还款
          var Fmonthevery = Fmontheverybus + Fmontheverygjj
          this.everyplay = Fmonthevery.toFixed(2) // 每月还款
          var Frate = Fratebus + Frategjj
          this.interest = Frate.toFixed(2)
          var Fdecreased = monthbjbus * (loanrate1bus / 1200) + monthbjgjj * (loanrate2gjj / 1200)
          this.decrease = Fdecreased.toFixed(2) // 每月递减
        }
        if (this.busrate[0] === '自定义利率' && this.gjjrate[0] !== '自定义利率' && this.gjjrate[0] !== '请选择') {
          var Gratebus = (loanTime + 1) * loanmoneybus * (loanrate2bus / 1200) / 2
          var Gtotalbus = Gratebus + loanmoneybus
          var Gmontheverybus = loanmoneybus / loanTime + loanmoneybus * (loanrate2bus / 1200)
          var Grategjj = (loanTime + 1) * loanmoneygjj * (loanrate1gjj / 1200) / 2
          var Gtotalgjj = Grategjj + loanmoneygjj
          var Gmontheverygjj = loanmoneygjj / loanTime + loanmoneygjj * (loanrate1gjj / 1200)
          var Gtotal = Gtotalbus + Gtotalgjj
          this.totalplay = Gtotal.toFixed(2) // 总还款
          var Gmonthevery = Gmontheverybus + Gmontheverygjj
          this.everyplay = Gmonthevery.toFixed(2) // 每月还款
          var Grate = Gratebus + Grategjj
          this.interest = Grate.toFixed(2)
          var Gdecreased = monthbjbus * (loanrate2bus / 1200) + monthbjgjj * (loanrate1gjj / 1200)
          this.decrease = Gdecreased.toFixed(2) // 每月递减
        }
      }
    },
    zhmonthdebj () { // 组合贷款  按每月还款计算  等额本金
      var loantime = this.value1[0]
      loantime = parseFloat(loantime) * 12 // 贷款期限
      if (this.loanall === '') {
        var loanrate1bus = this.value2[0].slice(5)
        loanrate1bus = parseFloat(loanrate1bus) // 贷款年利率 （选择）
        var Kloanrate2bus = this.value3
        Kloanrate2bus = parseFloat(Kloanrate2bus) // 贷款年利率（自定义）
        var money0 = parseFloat(this.value0) // 每月还款金额
        // var allmoney =  this.loanall // 可贷公积金总额
        var monthratebus = Math.pow((1 + loanrate1bus / 1200), loantime)
        var moneybus = (money0 * (monthratebus - 1)) / ((loanrate1bus / 1200) * monthratebus)
        this.money = moneybus.toFixed(2) // 贷款金额
        if (this.value2[0] !== '请选择' && this.value2[0] !== '自定义利率') {
          this.loan0 = 100
          this.soult = true
          var min = ((moneybus / loantime) + (moneybus - 0) * (loanrate1bus / 1200)) - ((moneybus / loantime) + (moneybus - moneybus / loantime) * (loanrate1bus / 1200)) // 每月递减
          var ratebus = loantime * min + loantime * (loantime - 1) / 2 * min // 总利息
          this.interest = ratebus.toFixed(2)
          var total = ratebus + moneybus
          this.busloanval = this.money
          this.gjjloanval = '0.00'
          this.everyplay = money0.toFixed(2) // 每月还款
          this.totalplay = total.toFixed(2) // 总还款额
          this.decrease = min.toFixed(2) // 每月递减
        }
        if (this.value2[0] === '自定义利率') {
          this.loan0 = 100
          this.soult = true
          var Jmin = ((moneybus / loantime) + (moneybus - 0) * (Kloanrate2bus / 1200)) - ((moneybus / loantime) + (moneybus - moneybus / loantime) * (Kloanrate2bus / 1200)) // 每月递减
          var Jratebus = loantime * Jmin + loantime * (loantime - 1) / 2 * Jmin // 总利息
          this.interest = Jratebus.toFixed(2)
          var Jtotal = Jratebus + moneybus
          this.busloanval = this.money
          this.gjjloanval = '0.00'
          this.everyplay = money0.toFixed(2) // 每月还款
          this.totalplay = Jtotal.toFixed(2) // 总还款额
          this.decrease = Jmin.toFixed(2) // 每月递减
        }
      }
      if (this.loanall !== '') {
        var loanrate1gjj = this.gjjrate[0].slice(5)
        loanrate1gjj = parseFloat(loanrate1gjj) // 贷款年利率 （选择）
        var loanrate2gjj = this.zdygjjloan
        loanrate2gjj = parseFloat(loanrate2gjj) // 贷款年利率（自定义）
        var Nmoney0 = parseFloat(this.value0) // 每月还款金额
        // var Kallmoney =  this.loanall // 可贷公积金总额
        var monthrategjj = Math.pow((1 + loanrate1gjj / 1200), loantime)
        var moneygjj = (Nmoney0 * (monthrategjj - 1)) / ((loanrate1gjj / 1200) * monthrategjj)
        this.money = moneygjj.toFixed(2) // 贷款金额
        if (this.gjjrate[0] !== '请选择' && this.gjjrate[0] !== '自定义利率') {
          this.loan0 = 100
          this.soult = true
          var Nmin = ((moneygjj / loantime) + (moneygjj - 0) * (loanrate1gjj / 1200)) - ((moneygjj / loantime) + (moneygjj - moneygjj / loantime) * (loanrate1gjj / 1200)) // 每月递减
          var rategjj = loantime * Nmin + loantime * (loantime - 1) / 2 * Nmin // 总利息
          this.interest = rategjj.toFixed(2)
          var Ntotal = rategjj + moneygjj
          this.busloanval = '0.00'
          this.gjjloanval = this.money
          this.everyplay = Nmoney0.toFixed(2) // 每月还款
          this.totalplay = Ntotal.toFixed(2) // 总还款
          this.decrease = Nmin.toFixed(2) // 每月递减
        }
        if (this.gjjrate[0] === '自定义利率') {
          this.loan0 = 100
          this.soult = true
          var Xmin = ((moneygjj / loantime) + (moneygjj - 0) * (loanrate2gjj / 1200)) - ((moneygjj / loantime) + (moneygjj - moneygjj / loantime) * (loanrate2gjj / 1200)) // 每月递减
          var Xrategjj = loantime * Xmin + loantime * (loantime - 1) / 2 * Xmin // 总利息
          this.interest = Xrategjj.toFixed(2)
          var Xtotal = Xrategjj + moneygjj
          this.busloanval = '0.00'
          this.gjjloanval = this.money
          this.everyplay = Nmoney0.toFixed(2) // 每月还款
          this.totalplay = Xtotal.toFixed(2) // 总还款额
          this.decrease = Xmin.toFixed(2) // 每月递减
        }
      }
    }
  }
}
</script>
